package com.clouddisk.file.config;

import com.clouddisk.file.chain.FileOperationHandler;
import com.clouddisk.file.chain.impl.FileNameHandler;
import com.clouddisk.file.chain.impl.FileUploadHandler;
import com.clouddisk.file.chain.impl.StorageCheckHandler;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class FileOperationConfig {

    @Bean
    public FileOperationHandler fileOperationChain(
            FileNameHandler fileNameHandler,
            StorageCheckHandler storageCheckHandler,
            FileUploadHandler fileUploadHandler) {
        
        // 构建责任链：文件名处理 -> 存储空间检查 -> 文件上传
        fileNameHandler.setNext(storageCheckHandler);
        storageCheckHandler.setNext(fileUploadHandler);
        
        return fileNameHandler;
    }
} 